package com.qingfeng.testandroid12sdkdemo.data.db

import android.content.Context
import android.util.AttributeSet
import android.view.ViewGroup
import androidx.annotation.AttrRes
import androidx.room.Database
import androidx.room.Room
import androidx.room.RoomDatabase
import com.blankj.utilcode.util.Utils
import com.qingfeng.testandroid12sdkdemo.data.db.dao.HomeDao
import com.qingfeng.testandroid12sdkdemo.data.db.migration.MIGRATION
import com.qingfeng.testandroid12sdkdemo.data.entity.BannerBean
import com.qingfeng.testandroid12sdkdemo.data.entity.HomeListBean

@Database(entities = [HomeListBean::class, BannerBean::class], version = 2, exportSchema = false)
abstract class YanDatabase : RoomDatabase(){

    abstract fun HomeLocalData() : HomeDao

    companion object {
        fun getInstance() = SingletonHolder.INSTANCE
    }

    private object SingletonHolder {
        val INSTANCE = Room.databaseBuilder(
            Utils.getApp(),
            YanDatabase::class.java,
            "yan_db"
        ).addMigrations(MIGRATION.MIGRATION_1_2).build()
    }

}

